/*
 * SimSphere.h
 *
 *  Created on: Apr 20, 2011
 *      Author: varunjn
 */

#ifndef SIMSPHERE_H_
#define SIMSPHERE_H_

#include <opal.h>
#include "SimSolid.h"
#include "Entity.h"
#include "SphereEntity.h"

class SimSphere : public SimSolid {

public:

	double radius;

	SimSphere(opal::Solid *s, std::vector<opalSamples::Entity*> *ent):SimSolid(s, ent){

	}

	virtual void create() {

		solid->setTransform(transform);
		opalSamples::Entity* entity = NULL;

		solid->setStatic(isStatic);
		//(*solid)->setLinearDamping(0.2);

		opal::SphereShapeData sphereData;
		sphereData.radius = radius;
		sphereData.offset.translate(0.0, 0.0, 0.0);
		sphereData.material.friction = friction;
		solid->addShape(sphereData);

		entity = new opalSamples::SphereEntity();
		((opalSamples::SphereEntity*)entity)->setRadius(sphereData.radius);
/*
		opal::Vec3r color(randomRealUniform(0, (opal::real)0.7),
			randomRealUniform(0, (opal::real)0.7),
			randomRealUniform(0, (opal::real)0.7));
*/
		entity->setColor(randomRealUniform(0, 0.7),
				randomRealUniform(0, 0.7),
				randomRealUniform(0, 0.7));

		entity->attachToSolid(solid);
		gEntities->push_back(entity);
	}

};

#endif /* SIMSPHERE_H_ */
